// 获取图片数据
function getImage (src) {
  return new Promise((resolve, reject) => {
    // console.log(this);
    console.log('图片连接获取成功')
    const img = document.createElement('img')
    img.src = src
    img.onload = () => {
      console.log('图片加载中')
      resolve(img)
    }
    img.onerror = () => {
      reject(new Error('图片加载失败'))
    }
  }).then(img => {
    document.body.appendChild(img)
  }).catch(err => {
    document.body.innerHTML = err
  })
}

getImage('./images/嘉然loading.gif')
